package feng.iLocator.Overlay;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class LineOverlay extends Overlay 
{
	private GeoPoint start = null;
	private GeoPoint end = null;
	
	public LineOverlay (GeoPoint st, GeoPoint ed)
	{
		this.start = st;
		this.end = ed;
	}

	@Override
	public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
			long when) 
	{
		Paint paint = new Paint ();
		paint.setARGB(250, 40, 230, 60);
		paint.setAntiAlias(true);
		paint.setFakeBoldText(true);
		paint.setDither(true);  
        paint.setStyle(Paint.Style.STROKE);  
        paint.setStrokeJoin(Paint.Join.ROUND);  
        paint.setStrokeCap(Paint.Cap.ROUND);  
        paint.setStrokeWidth(5);
        
		if (! shadow)
		{
			Projection proj = mapView.getProjection();
			Point a = new Point ();
			proj.toPixels(this.start, a);
			Point b = new Point ();
			proj.toPixels(this.end, b);
			Path path = new Path ();
			path.moveTo(a.x, a.y);
			path.lineTo(b.x, b.y);
			canvas.drawPath(path, paint);
		}
		
		return super.draw(canvas, mapView, shadow, when);
	}
	

}
